// Copyright 2022 a.o.smith ALL Rights Reserved
package com.liuxinlong.enums;

import org.apache.commons.lang3.StringUtils;

/**
 * 文件类型枚举
 *
 * @author liuxinlong@hotwater.com.cn
 * @version 1.0.0
 * @since 2022-06-15
 */
public enum FileTypeEnum {
    BMP("bmp","image/bmp"),
    GIF("gif","image/gif"),
    JPEG("jpeg","image/jpeg"),
    JPG("jpg","image/jpeg"),
    PNG("png","image/png"),
    TIFF("tiff","image/tiff"),
    DCX("dcx","image/x-dcx"),
    PCX("pcx","image/x-pcx"),
    HTML("html","text/html"),
    TXT("txt","text/plain"),
    XML("xml","text/xml"),
    AFP("afp","application/afp"),
    PDF("pdf","application/pdf"),
    RTF("gif","application/afp"),
    DOC("doc","application/msword"),
    DOCX("docx","application/msword"),
    PPT("ppt","application/vnd.ms-powerpoint"),
    PPTX("pptx","application/vnd.ms-powerpoint"),
    XLS("xls","application/vnd.ms-excel"),
    XLSX("xlsx","application/vnd.ms-excel");

    private String value;

    private String name;

    FileTypeEnum(String value, String name) {
        this.value = value;
        this.name = name;
    }

    public String getValue() {
        return value;
    }

    public String getName() {
        return name;
    }

    public static String getNameByValue(String value) {
        FileTypeEnum arrObj[] = FileTypeEnum.values();
        for (FileTypeEnum obj : arrObj) {
            if (StringUtils.equals(value,obj.getValue())) {
                return obj.getName();
            }
        }
        return " ";
    }
}
